from .models import DeviceInfo
from django import forms
from django.contrib.auth.models import User


class CreateDeviceInfoForm(forms.ModelForm):
    class Meta:
        model = DeviceInfo
        fields = "__all__" #全部继承
        labels={
            'device_name':'设备名称',
             'device_id':'设备编号',
            'device_model':'设备型号',
            'device_addr':'设备地址',
            'created_time':'创建时间',
            'updated_time':'更新时间'
        }


class CreateAdminInfoForm(forms.ModelForm):
    class Meta:
        model = User
        #fields = "__all__" #全部继承
        fields = {'username','is_active','is_staff','groups','user_permissions','password','email'} # 全部继承
        labels = {
            'username': '姓名',
            'email': '邮箱',
            'password': '密码',
            'password1': '密码',
            'is_superuser':'超级管理员'
        }

class UserLoginForm(forms.ModelForm):
    username = forms.CharField(widget=forms.TextInput(), label='用户')
    password = forms.CharField(widget=forms.PasswordInput, label='密码')
    email=forms.CharField(widget=forms.EmailInput(), label='Email')
    class Meta:
        model = User
        fields = ('username', 'password','email')
        widgets = {}
# 重新声明注册函数定义那些内容
class UserRegisterForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ('username', 'password','email')
        widgets = {}